﻿using System;
using System.Collections.Specialized;
using System.IO;
using System.Web;

namespace talkin
{
    public class BasePage : System.Web.UI.Page
    {

        protected void Page_Init()
        {
            //HttpCookie cookie = new HttpCookie("JoySpots");
            //cookie.Values["busid"] = "123";
            //cookie.Values["rtid"] = "810";
            //cookie.Values["gob"] = "";
            //cookie.Values["city"] = "";

            //Request.Cookies.Add(cookie);

            NameValueCollection querystring = Request.QueryString;
            HttpCookie buscookie = Request.Cookies["JoySpots"];

            if (buscookie != null && (querystring["busid"] == null || querystring["rtid"] == null || querystring["gob"] == null || querystring["city"] == null))
            {
                string busid = buscookie.Values["busid"] ?? "";
                string rtid = buscookie.Values["rtid"] ?? "";
                string gob = buscookie.Values["gob"] ?? "";
                string city = buscookie.Values["city"] ?? "";

                Server.Transfer(String.Format("{0}?busid={1}&rtid={2}&gob={3}&city={4}", Path.GetFileName(Request.Url.AbsolutePath), busid, rtid, gob, city));
            }
        }
    }
}